package com.tanhua.server.controller;

import com.tanhua.common.utils.UserThreadLocal;
import com.tanhua.server.service.PeachBlossomService;
import com.tanhua.server.vo.PeachBlossom;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping
@Slf4j
public class PeachBlossomController {

    @Autowired
    private PeachBlossomService peachBlossomService;

    /**
     * 桃花传音——接收语音
     *
     * @param
     * @return
     */
    @GetMapping("/peachblossom")
    public ResponseEntity<PeachBlossom> queryPeachBlossom() {
        try {
            PeachBlossom peachBlossom = this.peachBlossomService.queryPeachBlossom();
            if (null != peachBlossom) {
                return ResponseEntity.ok(peachBlossom);
            }
        } catch (Exception e) {
            log.error("接收语音出错~ userID = " + UserThreadLocal.get().getId(), e);
        }
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
    }
}
